﻿using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoreDB.Extensions
{
    public static class ConnectorExtension
    {
        public static XYZ Direction(this Connector connector)
        {
            return connector.CoordinateSystem.BasisZ;
        }
        public static bool ConnectToSafely(this Connector connector, Connector another)
        {
            if (connector.ConnectorType != another.ConnectorType)
                return false;
            XYZ origin;
            XYZ anotherOrigin;
            try
            {
                origin = connector.Origin;
                anotherOrigin = another.Origin;
                if (!origin.IsEqual(anotherOrigin))
                    return false;
                connector.ConnectTo(another);
            }
            catch
            {
                return false;
            }
            return true;
        }


    }
}
